/************************************************************
 * Copyright (C), 2020-2030, ripnano. Co., Ltd.
 * FileName:        global_ui.h
 * Author:			Dan Yin
 * Date:            2022-06-08
 * Description:		the global definition file for UI varibales
 * Version:			1.0.0.0
 **********************************************************/

#ifndef GLOBAL_UI_H
#define GLOBAL_UI_H

#include <QListView>
#include <QDesktopWidget>
#include "utils/defines/def_business_rules.h"

#define DEF_MAINFRAME_WIDTH             1024
#define DEF_MAINFRAME_HEIGHT            600
#define DEF_MAIN_WIDGET_HEIGHT          520
#define DEF_STATUS_BAR_HEIGHT           30
#define DEF_TOOL_BAR_HEIGHT             50
#define DEF_CUR_CHANNEL_SIZE            1
#define DEF_HEAT_CHANNEL_SIZE           4
#define DEF_CT_VALUE_ACCURACY           1
#define DEF_THRESHOLD_VALUE_ACCURACY    1
#define DEF_RESET_TIME_CONSUME          70
#define DEF_STEP_ICON_FILE2             ":/images/share/icon/file2.png"
#define DEF_STEP_ICON_FILE3             ":/images/share/icon/file3.png"
#define DEF_SPLIT_SEMICOLON             ";"
#define DEF_SPLIT_COMMA                 ","
#define DEF_SPLIT_THRESHOLD             "/"
#define DEF_MELTING_MODE                6
#define DEF_FILTER_FILE_EXTRACT         "ext"
#define DEF_FILTER_FILE_PCR             "pcr"
#define DEF_FILTER_FILE_FLOW            "flw"

#define DF_NAME_LOAD_TIPS               "A"
#define DF_NAME_UNLOAD_TIPS             "B"
#define DF_NAME_PIERCE                  "C"
#define DF_NAME_MAG_SLEEVE              "D"
#define DF_NAME_MAG_SLEEVE_FAST         "E"
#define DF_NAME_MAG_SLEEVE_SLOW         "F"
#define DF_NAME_TIP_SUCTTION            "G"
#define DF_NAME_TIP_SPIT                "H"
#define DF_NAME_TIP_MIXING              "I"
#define DF_NAME_TIP_HEATING             "J"

#define DF_AREA_EXTRACT                 "e"
#define DF_AREA_SPECIMEN                "s"
#define DF_AREA_REACTION                "r"

#define SET_STYLE_SHEET(sFile) \
QFile qssFile(sFile); \
if(qssFile.open(QFile::ReadOnly)) { \
    this->setStyleSheet(qssFile.readAll()); \
    qssFile.close(); \
} \

enum EM_INPUT_TYPE {
    E_IT_STEP_NAME,
    E_IT_SIZE
};

enum EUM_WIDGET_ACTIOIN {
    E_WA_LOGIN,
    E_WA_HOME,
    E_WA_HISTORY_RESULT,
    E_WA_HISTORY_QUERY,
    E_WA_SETTING,
    E_WA_FACTORY,
    E_WA_FAC_MOTOR_DEBUG,

    E_WA_RESULT_DELETE,
    E_WA_RESULT_INFO_MODIFY,

    E_WA_FAC_SAMPLE_TEST_STOP,

    E_WA_FAC_PCR_TEST_START,
    E_WA_FAC_PCR_TEST_STOP,
    E_WA_FAC_PCR_STAGE_ADD,
    E_WA_FAC_PCR_TEST_OPEN,
    E_WA_FAC_PCR_TEST_IMPORT,
    E_WA_FAC_PCR_TEST_NEW,
    E_WA_FAC_PCR_TEST_EDIT,
    E_WA_FAC_PCR_TEST_SAVE_AS,
    E_WA_FAC_PCR_TEST_DELETE,

    E_WA_FAC_PROCESS_TEST_START,
    E_WA_FAC_PROCESS_TEST_STOP,
    E_WA_FAC_PROCESS_TEST_OPEN,
    E_WA_FAC_PROCESS_TEST_IMPORT,
    E_WA_FAC_PROCESS_TEST_NEW,
    E_WA_FAC_PROCESS_TEST_EDIT,
    E_WA_FAC_PROCESS_TEST_SAVE_AS,
    E_WA_FAC_PROCESS_TEST_DELETE,

    E_WA_FAC_EXTRACT_TEST_START,
    E_WA_FAC_EXTRACT_TEST_STOP,
    E_WA_FAC_EXTRACT_TEST_OPEN,
    E_WA_FAC_EXTRACT_TEST_IMPORT,
    E_WA_FAC_EXTRACT_TEST_NEW,
    E_WA_FAC_EXTRACT_TEST_EDIT,
    E_WA_FAC_EXTRACT_TEST_SAVE_AS,
    E_WA_FAC_EXTRACT_TEST_DELETE,

    E_WA_FAC_INFUSE_TEST_START,
    E_WA_FAC_INFUSE_TEST_STOP,

    E_WA_FAC_KIT_LIST,
    E_WA_FAC_KIT_LIST_OPEN,
    E_WA_FAC_KIT_LIST_ADD,
    E_WA_FAC_KIT_LIST_SCAN,
    E_WA_FAC_KIT_LIST_SAVE,
    E_WA_FAC_KIT_LIST_SAVE_AS,
    E_WA_FAC_KIT_LIST_DELETE,
    E_WA_FAC_KIT_PROCESS_LIST,
    E_WA_FAC_KIT_PCR_LIST,

    E_WA_FAC_HEATING_DEBUG_START,
    E_WA_FAC_HEATING_DEBUG_STOP,
    E_WA_FAC_HEATING_DEBUG_EXPORT,
    E_WA_FAC_FLUOR_DEBUG_START,
    E_WA_FAC_FLUOR_DEBUG_STOP,
    E_WA_FAC_FLUOR_DEBUG_EXPORT,
    E_WA_PROC_DEL_FILE,
    E_WA_PROC_FACTORY_RECOVER,
    E_WA_PROC_TURN_ON_UV_LIGHT,
    E_WA_PROC_MODIFY_PARAMS,

    E_WA_FAC_SAMPLE_TYPE_LIST,
    E_WA_FAC_SAMPLE_TYPE_NEW,
    E_WA_FAC_SAMPLE_TYPE_EDIT,
    E_WA_FAC_SAMPLE_TYPE_DELETE,

    E_WA_SET_DATA_BACKUP,
    E_WA_SET_DATA_RESTORE,
    E_WA_SET_DATA_RESTORE_FACTORY,
    E_WA_SIZE
};

enum EUM_RUNNING_STATES {
    E_RS_IDLE,
    E_RS_READY,
    E_RS_IAP_DOING,
    E_RS_IAP_CANCELED,
    E_RS_IAP_FAILED,
    E_RS_IAP_ABORT,
    E_RS_IAP_COMPLETED,
    E_RS_PCR_DOING,
    E_RS_PCR_CANCELED,
    E_RS_PCR_FAILED,
    E_RS_PCR_ABORT,
    E_RS_PCR_COMPLETED,
    E_RS_STOPED,
    E_RS_FINISH
};

enum EUM_TASK_TYPE {
    E_TT_NONE,
    E_TT_SAMPLE_TEST,
    E_TT_PROCESS_DEBUG,
    E_TT_HEATING_DEBUG,
    E_TT_PCR_DEBUG,
    E_TT_INFUSE_DEBUG
};

typedef struct ST_RESULT_QUERY_PARAM
{
    QString sDateBegin;
    QString sDateEnd;
    QString sTubeBarcode;
    QString sKitBarcode;

    ST_RESULT_QUERY_PARAM() {
        sDateBegin = "";
        sDateEnd = "";
        sTubeBarcode = "";
        sKitBarcode = "";
    }
}RESULT_QUERY_PARAM;

typedef struct ST_MELT_PARAM {
    float   fTempStart;
    float   fTempStop;
    float   fTempRate;

    ST_MELT_PARAM() {
        clear();
    }
    void clear() {
        fTempStart = 0;
        fTempStop = 0;
        fTempRate = 1;
    }
}MELT_PARAM;

typedef struct ST_PCR_PROC_ENTRY {
    float   fTemperature;
    float   fFinalTemp;
    float   fTempRate;
    float   fDuration;
    bool    bDetect;

    ST_PCR_PROC_ENTRY() {
        fFinalTemp = 0;
        fTempRate = 0;
        fDuration = 0;
        fTemperature = 0;
        bDetect = false;
    }
}SPCR_PROC_ENTRY;

typedef struct ST_PCR_PROC_STAGE {
    int nType;
    int nCycles;
    QList<ST_PCR_PROC_ENTRY> lstEntry;

    ST_PCR_PROC_STAGE() {
        nType = 0;
        nCycles = 0;
        lstEntry.clear();
    }
}PCR_PROC_STAGE;

typedef struct ST_PCR_PROCEDURE {
    QString sProcedureName;
    QList<ST_PCR_PROC_STAGE> lstStage;
    int nTimeConsume;

    ST_PCR_PROCEDURE() {
        clear();
    }

    void clear() {
        sProcedureName = "";
        lstStage.clear();
        nTimeConsume = 0;
    }
}PCR_PROCEDURE;

typedef struct ST_PROCESS_PROCEDURE {
    QString sProcedureName;
    QString sProcessContent;
    int nTimeConsume;
    int nKitType;

    ST_PROCESS_PROCEDURE() {
        clear();
    }

    void clear() {
        sProcedureName = "";
        sProcessContent = "";
        nTimeConsume = 0;
        nKitType = 0;
    }
}PROCESS_PROCEDURE;

typedef struct ST_CHANNEL_INFO {
    int nChannelNumber;
    int nSampleTypeId;
    QString sTubeBarcode;
    QString sKitBarcode;

    ST_CHANNEL_INFO() {
        clear();
    }

    void clear() {
        nChannelNumber= 0;
        nSampleTypeId = 0;
        sTubeBarcode = "";
        sKitBarcode = "";
    }
}CHANNEL_INFO;

typedef struct ST_KIT_INFO {
    QString sKitBarcode;
    QString sItemName;
    QString sItemAbbreviation;

    ST_KIT_INFO() {
        clear();
    }

    void clear() {
        sKitBarcode.clear();
        sItemName.clear();
        sItemAbbreviation.clear();
    }
}KIT_INFO;

typedef struct ST_THRESHOLD_INFO {
    int     nBaselineStartIdx;
    double  arrThresholdValue[DEF_FLUO_CH_SIZE];

    ST_THRESHOLD_INFO() {
        clear();
    }

    void clear() {
        nBaselineStartIdx = 0;
        memset(arrThresholdValue, 0, sizeof(double) * DEF_FLUO_CH_SIZE);
    }
}THRESHOLD_INFO;

Q_DECLARE_METATYPE(ST_KIT_INFO);
Q_DECLARE_METATYPE(ST_THRESHOLD_INFO);
Q_DECLARE_METATYPE(ST_RESULT_QUERY_PARAM);

#endif // GLOBAL_UI_H
